package com.zhoujinlong.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.core.ui.BaseSwipeBackActivity;
import com.android.core.widget.SwipeBackLayout;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.zhoujinlong.R;
import com.zhoujinlong.model.bean.ExerciseBean;
import com.zhoujinlong.ui.widget.TitleBar;
import com.zhoujinlong.utils.BaseUtil;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * author meikoz on 2016/4/19.
 * email  meikoz@126.com
 */
public class DetailActivity extends BaseSwipeBackActivity {

    @Bind(R.id.title_bar)
    TitleBar mTitleBar;
    @Bind(R.id.tv_detail_title)
    TextView mTvTitle;
    @Bind(R.id.iv_pic_des)
    ImageView mIvPicDes;
    @Bind(R.id.tv_des)
    TextView mTvDes;

    public static void start(Context context, ExerciseBean exerciseBean) {
        Intent intent = new Intent(context, DetailActivity.class);
        intent.putExtra("obj", exerciseBean);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_detail);
        ButterKnife.bind(this);
        mTitleBar.setTitle(getString(R.string.tab_text_home));
        ExerciseBean exerciseBean = (ExerciseBean) getIntent().getSerializableExtra("obj");
        mTvTitle.setText(exerciseBean.getTitle());
        Glide.with(DetailActivity.this).load(BaseUtil.getDrawableId(DetailActivity.this, exerciseBean.getPicture())).placeholder(R.drawable.loading).diskCacheStrategy(DiskCacheStrategy.SOURCE).into(mIvPicDes);
        mTvDes.setText(exerciseBean.getDescribeText());
        setDragEdge(SwipeBackLayout.DragEdge.LEFT);
    }
}
